package study.domain.blog;

import java.io.Serializable;

import javax.persistence.Embeddable;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;

import lombok.Data;
import study.domain.user.User;

@Embeddable
@Data
public class FriendId implements Serializable {

	private static final long serialVersionUID = 1700631379187693634L;

	@OneToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "user_id", nullable = false, updatable = false)
	@org.hibernate.annotations.ForeignKey(name = "fk_friends_user_id")
	private User user;

	@OneToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "friend_id", nullable = false, updatable = false)
	@org.hibernate.annotations.ForeignKey(name = "fk_friends_friend_id")
	private User friend;

	public FriendId() {

	}

	public FriendId(Long userId, Long friendId) {
		this(new User(userId), new User(friendId));
	}

	public FriendId(User user, User friend) {
		this.user = user;
		this.friend = friend;
	}
}
